package com.knowif.backend.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.knowif.pojo.UserCollectExample;
import com.knowif.search.SearchCondition;
import com.knowif.service.UserCollect_service;
import com.knowif.system.model.RestBean;
import com.knowif.util.ExampleUtil;


@Service
public class UserCollectService {
	
	@Autowired
	private UserCollect_service userCollect_service;
	
	/**
	 * @author: xingyao 
	 * @Description:  用户收藏实现
	 * @param userId  收藏者id
	 * @param beUserId	被收藏者id
	 * @return
	 */
	public RestBean<?> addCollect(Integer userId,Integer beUserId){
		if(userId == null || userId == 0){
			return RestBean.buildError("请输入userId",RestBean.NOTUSERID);
		}
		if(beUserId == null || beUserId == 0){
			return RestBean.buildError("请输入被收藏者id");
		}
		return userCollect_service.addCollect(userId, beUserId);
	}
	
	
	
	/**
	 * @author: xingyao 
	 * @Description:  查看用户收藏导师信息
	 * @param searchCondition
	 * @return
	 */
	public RestBean<?> selectCollect(SearchCondition searchCondition){
		if(searchCondition == null){
			return RestBean.buildError("请输入查询条件");
		}
		try {
			UserCollectExample userCollectExample = (UserCollectExample)ExampleUtil.buildExample(new UserCollectExample(), searchCondition);
			return userCollect_service.selectCollect(userCollectExample);
		} catch (Exception e) {
			return RestBean.buildError("系统出错，请稍后再试");
		}
	}
	
	
	/**
	 * @author: xingyao 
	 * @Description:  删除用户收藏导师记录
	 * @param userCollectId
	 * @return
	 */
	public RestBean<?> deleteCollect(Integer userCollectId){
		return userCollect_service.deleteCollect(userCollectId);
	}
	
	
	/**
	 * @author: xingyao 
	 * @Description:  批量删除用户收藏导师记录
	 * @param userCollectId
	 * @return
	 */
	public RestBean<?> deleteCollects(List<Integer> userCollectId){
		return userCollect_service.deleteCollects(userCollectId);
	}
	

	
}
